import {TestBed, inject} from '@angular/core/testing';
import {HttpClient} from "@angular/common/http";
import {HttpClientTestingModule} from "@angular/common/http/testing";

import {Observable} from "rxjs/Observable";
import "rxjs/add/observable/of";

import {InsuredClientDetailProvider} from "./insured-client-detail.provider";
import {Level} from "../../../model/pages/client/holder-client-detail/holder-client-detail.model";

describe('HolderClientDetailProvider',()=>{
    let httpClient:HttpClient;
    let insuredClientDetailProvider:InsuredClientDetailProvider;
    beforeEach(()=>{
        TestBed.configureTestingModule(({
            providers:[InsuredClientDetailProvider],
            imports:[HttpClientTestingModule]
        }));
        httpClient = TestBed.get(HttpClient);
        insuredClientDetailProvider=new InsuredClientDetailProvider(TestBed.get(HttpClient));
    });

    // 测试provider模块
    /*it('should be created',inject([InsuredClientDetailProvider],(provider:InsuredClientDetailProvider)=>{
        expect(provider).toBeTruthy();
    }));

    // 获取客户头像测试
    it('ClientDetailProvider getClientAvatar test',()=>{
        let testClient:BaseInfo=new BaseInfo();
        testClient.avatar='testUrl';
        let result=InsuredClientDetailProvider.getClientAvatar(testClient);
        expect(result).toEqual('testUrl');
    });
    it('ClientDetailProvider getClientAvatar test',()=>{
        let testClient:BaseInfo=new BaseInfo();
        testClient.sexCode='M';
        let result=InsuredClientDetailProvider.getClientAvatar(testClient);
        expect(result).toEqual('./assets/images/client/client-detail/ico_head_man.png');
    });

    // 测试金额转化
    it('ClientDetailProvider tranNum test',()=>{
        let result=InsuredClientDetailProvider.transNum('123456789.13');
        expect(result).toEqual('123,456,789.13')
    });

    // 测试获取客户数据请求
    it('ClientDetailProvider postNewScheduleItem test', () => {
        spyOn(httpClient, 'get').and.returnValue(Observable.of(true));
        insuredClientDetailProvider.getClientDetailData(123).subscribe(result=>{
            expect(result).toEqual(true);
        });
    });

    // 测试客户等级分级返回图标样式
    it('ClientDetailProvider getClientLevel test',()=>{
        let result=insuredClientDetailProvider.getClientLevel('123456789.13');
        expect(result).toEqual('')
    });*/

});
